package com.cskaoyan.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UserServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().append("user servlet");
        //根据请求url，然后找到该servlet下不同的方法来进行处理
        String requestURI = req.getRequestURI();
        //if-else或switch进行请求的分发

        //如何获得username和password
        String username = req.getParameter("username");
        String age = req.getParameter("age");
        Integer age2 = Integer.valueOf(age);

        //响应Json
        //String json = GsonUtil.
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    public void register(HttpServletRequest request,HttpServletResponse response){}
    public void modify(HttpServletRequest request,HttpServletResponse response){}
    public void delete(HttpServletRequest request,HttpServletResponse response){}
}

